using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Specialized;

namespace Be.Timvw.Framework.Web.Tests.UriHelper
{
    [TestClass]
    public class WhenBuildingParameterString
    {
        [TestMethod]
        public void ShouldReturnEmptyStringWhenParametersAreEmpty()
        {
            NameValueCollection parameters = new NameValueCollection();
            string actual = Web.UriHelper.BuildParameterString(parameters);

            string expected = string.Empty;

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ShouldReturnEmptyStringWhenParametersAreNull()
        {
            NameValueCollection parameters = null;
            string actual = Web.UriHelper.BuildParameterString(parameters);

            string expected = string.Empty;

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ShouldReturnKeyEqualsValue()
        {
            NameValueCollection parameters = new NameValueCollection();
            parameters.Add("Key", "Value");
            string actual = Web.UriHelper.BuildParameterString(parameters);

            string expected = "Key=Value";

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ShouldReturnKeyEqualsAndKeyEqualsOtherValue()
        {
            NameValueCollection parameters = new NameValueCollection();
            parameters.Add("Key", "Value");
            parameters.Add("Key", "OtherValue");
            string actual = Web.UriHelper.BuildParameterString(parameters);

            string expected = "Key=Value&Key=OtherValue";

            Assert.AreEqual(expected, actual);
        }
    }
}
